package net.danielthompson.danray.cameras;

import net.danielthompson.danray.structures.Point;
import net.danielthompson.danray.structures.Vector;

/**
 * Created by daniel on 1/12/14.
 */
public class SimpleCamera implements Camera {

   private Point _rearFocalPoint;

   public SimpleCamera(Point rearFocalPoint) {
      _rearFocalPoint = rearFocalPoint;
   }

   @Override
   public Point GetWorldPointForPixel(int x, int y) {
      return null;
   }

   @Override
   public Point GetWorldPointForPixel(double x, double y) {
      return null;
   }

   @Override
   public Vector[] GetInitialStochasticRaysForPixel(double x, double y, int SamplesPerPixel) {
      return new Vector[0];
   }

   @Override
   public Vector[] GetInitialStochasticRaysForPixel(int x, int y, int SamplesPerPixel) {
      Vector[] vectors = new Vector[SamplesPerPixel + SamplesPerPixel];
      int vectorPointer = 0;
      for (double i = 0.0; i < SamplesPerPixel; i++) {
         double newX = x + ((i + 1.0) / ((double)SamplesPerPixel + 1.0));
         for (double j = 0.0; j < SamplesPerPixel; j++) {
            double newY = y + ((j + 1.0) / ((double)SamplesPerPixel + 1.0));

            vectors[vectorPointer++] = new Vector(_rearFocalPoint, Point.Minus(new Point(newX, newY, 0), _rearFocalPoint));
         }
      }
      /*Point direction = new Point(x, y, 0).Minus(focalPoint);
      return new Vector(focalPoint, direction);*/
      return vectors;
   }

   @Override
   public Vector GetStochasticRayForPixel(double x, double y) {
      return null;
   }
}
